package com.kaishengit.service;

import java.io.ByteArrayOutputStream;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.DocumentDao;
import com.kaishengit.pojo.Document;
import com.kaishengit.util.PDFUtil;

@Service
@Transactional
public class DocumentService {

	@Resource
	private DocumentDao documentDao;

	public void save(Document doc) {
		documentDao.save(doc);
	}
	
	public void deleteById(int id){
		documentDao.delete(id);
	}

	public List<Document> findListByProperty(String propertyName, Object value) {
		return documentDao.findListByProperty(propertyName, value); 
	}

	public Document findById(Integer id) {
		return documentDao.findById(id);
	}
	
	public ByteArrayOutputStream createPDF(Document document){
		return PDFUtil.createpdf(document);
	}
	
}
